package com.syg.case03;

import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ControllerCase03 {

    @Autowired
    ACase03 acase03;

    @Autowired
    BCase03 bCase03;

    /**
     * 情况3：B类被aop增强，C类没被aop增强，并且类中方法没有@Transactional注解
     */
    @RequestMapping(value = "/case03",method = RequestMethod.GET)
    public void proxyClassTest(){
        // aopProxy1结果是true 此时是通过AOP增强的对象,因为切入点配置到了类
        boolean aopProxy1 = AopUtils.isAopProxy(acase03);
        // aopProxy1结果是false 此时是原始对象,因为切入点配置到了类,不包含本类,如果配置到包,就包含了
        boolean aopProxy2 = AopUtils.isAopProxy(bCase03);
        System.out.println("proxyClassTest result = " + aopProxy1);
        System.out.println("proxyClassTest result = " + aopProxy2);
    }
}
